﻿<%@ WebHandler Language="C#" Class="predictiveSearchProductLoadAll" %>

using System;
using System.Web;
using System.Data;

using AMCBO;
using AMCOBJ;

public class predictiveSearchProductLoadAll : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "application/x-json";
        string output = string.Empty;
        string searchTxt = string.Empty;
        if (context.Request.QueryString["keyword"].Trim() != null && context.Request.QueryString["keyword"].Trim() != " ")
        {
            searchTxt = context.Request.QueryString["keyword"].ToString().Trim(); ;
        }

        settings SetBO = new settings();
        settingsObj SetObj = new settingsObj();
        //cusObj.Cus_Fname = searchTxt;
        SetObj.FulProductNme = searchTxt;
        DataTable dt = new DataTable();
        dt = SetBO.predictiveSearchProductAll(SetObj);

        if (dt.Rows.Count > 0)
        {
            output = "[";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                output += "{\"prodName\":\"" + dt.Rows[i]["fulProdNme"] + "\"},";
            }
            if (output[output.Length - 1] == ',')
            {
                output = output.Substring(0, output.Length - 1);
            }
            output += "]";
        }
        context.Response.Write(output);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}